normal/menu: Use safe math to avoid an integer overflow
authorAlec Brown <alec.r.brown@oracle.com>
Tue, 4 Feb 2025 15:11:11 +0000 (15:11 +0000)
committerFelix Zielcke <fzielcke@z-51.de>
Thu, 3 Jul 2025 16:35:51 +0000 (18:35 +0200)
commitb93c7d9ef4b87208021597c79788e5b8fe6a0cef
treee484ca0f772ec4a6b855291de006abcc79ab4090
parenta2a86381e7610e6dcd40ab469a1557383ab6e817
normal/menu: Use safe math to avoid an integer overflow

The Coverity indicates that the variable current_entry might overflow.
To prevent this use safe math when adding GRUB_MENU_PAGE_SIZE to current_entry.

On the occasion fix limiting condition which was broken.

Fixes: CID 473853
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name normal-menu-Use-safe-math-to-avoid-an-integer-overflow.patch
grub-core/normal/menu.c